package domain;

import java.util.ArrayList;

public class Hero extends Unit {
	
	
	private int level;
	private int xp;
	private int xpToLevelUp;
	private final int FIRST_LEVEL = 100;
	private final int MAX_LEVEL = 30;
	
	private ArrayList<Item> inventory;
	private int gold;
	
	public Hero(String name, int strength, int dexterity, int wisdom, int constitution) {
		super(name, strength, dexterity, wisdom, constitution);
		this.setLevel(1);
		this.initXp();
		this.setXpToLevelUp(FIRST_LEVEL);
		inventory = new ArrayList<Item>();
		this.setGold(0);
	}

	public void levelUp(){
		if(getLevel() < MAX_LEVEL){
			this.setLevel(getLevel()+1);
			xpToLevelUp = (int) (getXpToLevelUp() * 1.2);
			this.updateStats();
			this.setCurrentHealth(getMaxHealth());
		}
	}
	
	private void updateStats() {
		// TODO Auto-generated method stub
		
	}

	//Add XP, keep leveling up when you reach treshold.
	public void addXp(int n) {
		this.xp = getXp() + n;
		while(getXp()>=getXpToLevelUp())
			levelUp();
	}
	public int getXp() {
		return xp;
	}

	public void initXp() {
		this.xp = 0;
	}
	

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}
	

	private void setGold(int i) {
		this.gold = i;		
	}
	
	private int getGold(int i) {
		return gold;
	}

	public int getXpToLevelUp() {
		return xpToLevelUp;
	}

	public void setXpToLevelUp(int xpToLevelUp) {
		this.xpToLevelUp = xpToLevelUp;
	}
	
}
